#include "JetActor.h"
#include "DebugTracer.h"

extern DebugTracer _DEBUGTRACER;

JetActor::JetActor(Ogre::SceneManager *scene, Jet *jet)
{
    m_jet = NULL;
    m_scene = NULL;
    m_entity = NULL;
    m_node = NULL;

    m_jet = jet;
    m_scene = scene;
    m_type = ActorType(JET);

    m_entity = m_scene->createEntity(jet->GetName(),jet->GetMeshName());
    m_node = m_jet->GetBodyNode();
    m_node->attachObject(m_entity);

    initCameras();
}
void JetActor::Update(float timedelta)
{
    m_jet->Update(timedelta);

}

void JetActor::initCameras()
{
    m_cameraList[V_CLOSE] = m_scene->createCamera("close_camera_" + m_jet->GetOwner()->GetName());

    m_cameraList[V_CLOSE]->lookAt(Ogre::Vector3(m_jet->GetSteeringNode()->getPosition().x,
                                                m_jet->GetSteeringNode()->getPosition().y,
                                                m_jet->GetSteeringNode()->getPosition().z + 1));
    m_cameraList[V_CLOSE]->setFOVy(Ogre::Degree(60));

    m_cameraList[V_CLOSE]->setPosition(Ogre::Vector3(0,2,-4));

    /*
    m_cameraList[V_CLOSE]->setPosition(m_jet->GetBodyNode()->getPosition().x,
                                     m_jet->GetBodyNode()->getPosition().y + 3,
                                     m_jet->GetBodyNode()->getPosition().z - 7);
    */

    m_cameraList[V_CLOSE]->setNearClipDistance(0.1f);

    m_jet->GetBodyNode()->attachObject(m_cameraList[V_CLOSE]);

    m_cameraList[V_FAR] = NULL;
    m_cameraList[V_INTERNAL] = NULL;
}
